<template>
  <div>
  <el-tree-select
    v-model="nv[fvData.fdName]"
    :data="cursiveData"
    check-strictly
    :props="treeProps"
    :render-after-expand="false"
    :multiple = "true"
    @change = "change"
    style="width:100%;"
  />
  </div>
</template>

<script>
import { ref, onMounted, computed } from 'vue'
import nvService from '../../api/NvService'
import cacheManage from '../../cache/CacheManage'
export default {
  name: 'FvTreeSelect',
  props: {
    fvData: {
      default: null,
      type: Object
    }
  },
  setup(props) {
    const cursiveData = ref([])
    const nv = computed(() => {
      return props.fvData.getNv();
    });
    const expression = JSON.parse(props.fvData.fdLayout.expression);
    onMounted(async () => {
      if (expression.ndCode && expression.nvCode && expression.codeFdName) {
        const nvMsg = await nvService.getNvByCode(cacheManage.getDefaultCommonInfo(), expression.ndCode, expression.nvCode, expression.codeFdName);
        if (!nvMsg.success) { return }
        cursiveData.value = [nvMsg.value];
      }
    })
    const treeProps = {
      label: expression.descFdName,
      value: expression.codeFdName,
      children: expression.ndName
    }
    return {
      nv,
      treeProps,
      cursiveData
    }
  },
  methods: {
  }
}
</script>

<style scoped>

</style>
